/**
* Copyright (C) 2021 All rights reserved.
*
* @file main.h
* @author Wang Haibin
* @email wanghaibin@qiyi.com
* @date Tue Apr 27 16:31:50 CST 2021
* @brief 模拟argv参数行为
*/
#include <iostream>
#include <stdio.h>
#include <string.h>

int main()
{
    int argc = 3;
    char* argv[argc];

    const char * conf_path = "/a/b/c/d/g/aa.conf";
    int cfl = strlen(conf_path) + 1;
    const char* proc_name = "iqy_bgp";
    const char* c_flag = "-c";
    int proclen = strlen(proc_name) + 1;
    int cl = strlen("-c") + 1;
    int arglen = proclen + cl + cfl;
    char* bgp_args_ = new char[arglen];
    { // 设置argv内容
        char* curpos = bgp_args_;
        memcpy(curpos, proc_name, proclen);
        argv[0] = curpos;
        curpos += proclen;
        memcpy(curpos, c_flag, cl);
        argv[1] = curpos;
        curpos += cl;
        memcpy(curpos, conf_path, cfl);
        argv[2] = curpos;
    }
    for (int i = 0; i < argc; ++i) {
        printf("xxxxxxxxxx %s\n", argv[i]);
    }
    delete[] bgp_args_;
    return 0;
}
